﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Client.Forms
{
    public partial class BeepTimeSettingForm : Form
    {
        List<NumericUpDown> ns = new List<NumericUpDown>();

        public BeepTimeSettingForm()
        {
            InitializeComponent();

            ns.AddRange(new NumericUpDown[] { generalNumericUpDown, generalEmptyNumericUpDown, tickNumericUpDown, tickEmptyNumericUpDown, normalNumericUpDown, normalEmptyNumericUpDown, zxNumericUpDown, zxEmptyNumericUpDown, kModelNumericUpDown, kModelEmptyNumericUpDown });

            generalNumericUpDown.TabIndex = 0;
            generalEmptyNumericUpDown.TabIndex = 1;
            tickNumericUpDown.TabIndex = 3;
            tickEmptyNumericUpDown.TabIndex = 4;
            normalNumericUpDown.TabIndex = 5;
            normalEmptyNumericUpDown.TabIndex = 6;
            zxNumericUpDown.TabIndex = 7;
            zxEmptyNumericUpDown.TabIndex = 8;
            kModelNumericUpDown.TabIndex = 9;
            kModelEmptyNumericUpDown.TabIndex = 10;

            generalNumericUpDown.Value = Managers.Manager.beepM.generalWav;
            generalEmptyNumericUpDown.Value = Managers.Manager.beepM.generalWavEmpty;
            tickNumericUpDown.Value = Managers.Manager.beepM.tickWav;
            tickEmptyNumericUpDown.Value = Managers.Manager.beepM.tickWavEmpty;
            normalNumericUpDown.Value = Managers.Manager.beepM.kNormalWav;
            normalEmptyNumericUpDown.Value = Managers.Manager.beepM.kNormalWavEmpty;
            zxNumericUpDown.Value = Managers.Manager.beepM.kZXModelWav;
            zxEmptyNumericUpDown.Value = Managers.Manager.beepM.kZXModelWavEmpty;
            kModelNumericUpDown.Value = Managers.Manager.beepM.kModelWav;
            kModelEmptyNumericUpDown.Value = Managers.Manager.beepM.kModelWavEmpty;

            generalNumericUpDown.AccessibleName = "音效时长";
            generalEmptyNumericUpDown.AccessibleName = "间隔时间";
            tickNumericUpDown.AccessibleName = "音效时长";
            tickEmptyNumericUpDown.AccessibleName = "间隔时间";
            normalNumericUpDown.AccessibleName = "自选时长";
            normalEmptyNumericUpDown.AccessibleName = "自选间隔";
            zxNumericUpDown.AccessibleName = "专注时长";
            zxEmptyNumericUpDown.AccessibleName = "专注间隔";
            kModelNumericUpDown.AccessibleName = "K线时长";
            kModelEmptyNumericUpDown.AccessibleName = "K线间隔";

            foreach(var i in ns)
            {
                i.ValueChanged += OnValueChanged;
            }
        }

        void OnValueChanged(object sender,EventArgs e)
        {
            Managers.Manager.beepM.generalWav = (int)generalNumericUpDown.Value;
            Managers.Manager.beepM.generalWavEmpty = (int)generalEmptyNumericUpDown.Value;
            Managers.Manager.beepM.tickWav = (int)tickNumericUpDown.Value;
            Managers.Manager.beepM.tickWavEmpty = (int)tickEmptyNumericUpDown.Value;
            Managers.Manager.beepM.kNormalWav = (int)normalNumericUpDown.Value;
            Managers.Manager.beepM.kNormalWavEmpty = (int)normalEmptyNumericUpDown.Value;
            Managers.Manager.beepM.kZXModelWav = (int)zxNumericUpDown.Value;
            Managers.Manager.beepM.kZXModelWavEmpty = (int)zxEmptyNumericUpDown.Value;
            Managers.Manager.beepM.kModelWav = (int)kModelNumericUpDown.Value;
            Managers.Manager.beepM.kModelWavEmpty = (int)kModelEmptyNumericUpDown.Value;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
